# import os,os.path
#
# names = ['member_workbench','market_industryoverview','search_video','search_article','search_album','rank_hot_video','tag_video_tag','search_video_activity','search_blogger','rank_author','search_price','monitor_blogger','monitor_video','monitor_live','search_brand','rank_brand','brand_launch','brand_diagnosis','search_goods','search_goods_video','rank_goods','search_live','rank_live','rank_gift','search_game','rank_game','favorite_blogger','favorite_brand','favorite_goods','favorite_video']
#
# d = os.path.abspath(r'H:\_备课文档\项目——短视频统计分析\b-video-stat\spider\spider\spiders')
# # for x in os.listdir(d):
# #     for name in names:
# #         if x.startswith(name):
# #             os.rename(os.path.join(d,x), os.path.join(d, 'spider_'+x))
# #
#
# # names = [f for f in os.listdir(d) if str(f).startswith('spider_')]
# # print(names)
#
# def gen_spider():
#     content = None
#     with open(d+'\demo.py', 'r', encoding='utf8') as file:
#         content = file.readlines()
#         for i,x in enumerate(content):
#             print(i, x)
#
#     def writeFile(path, content):
#         content2 = [x for x in content]
#         content2[5] = content2[5].replace('aaa', path)
#         content2[8] = content2[8].replace('aaa', path)
#         # print("'spider.pipelines_{}.SpiderPipeline'".format(path))
#         path = os.path.join(d, 'spider_'+ path+'.py')
#         with open(path, 'w', encoding='utf8') as file:
#             file.writelines(content2)
#
#     for name in names:
#         writeFile(name, content)
#
# gen_spider()
#
# def gen_pipeline():
#     content = None
#     with open(os.path.join(d, 'pipelines.py'), 'r', encoding='utf8') as file:
#         content = file.readlines()
#
#     for i,x in enumerate(content):
#         print(i, x)
#
#     def writeFile(path, content):
#         content2 = [x for x in content]
#         content2[2] = content2[2].replace('aaa', path)
#         content2[11] = content2[11].replace('aaa', path)
#         # print("'spider.pipelines_{}.SpiderPipeline'".format(path))
#         path = os.path.join(d, 'pipelines_'+ path+'.py')
#         with open(path, 'w', encoding='utf8') as file:
#             file.writelines(content2)
#
#     for name in names:
#         writeFile(name, content)


